package com.jcli.jb51_net.article._175980开关按钮;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ButtonClickExample extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Button button = new Button("Click me");

        button.setOnAction(e -> {
            if (!ButtonUtils.isFastClick(button)) {
                System.out.println("Button clicked!");
                // 这里放置按钮被点击后的逻辑
            } else {
                System.out.println("Too fast! Ignoring click.");
                // 这里放置点击太快时的逻辑
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(button);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Button Click Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
